/*
	2007-12-4 List Widget Implement 
*/
#pragma once
#include ".\container.h"
#include <vector>
#define SEPERATE_LINE_DY	0
#define POINT_TEST_OFFSET	1
#define MOUSE_OVER_COLOR 0xFF
#define FLOAT_ITEM_ALPHA	100
#define MASK_ALPHA	0x50
#include "AnimateController.h"
#include "CBackGroundWidget.h"
#include "CMaskWidget.h"
class DLL_EXP CListItemInterfae{
public:
	CListItemInterfae(){};
	virtual ~CListItemInterfae(){
	};
	
};
class DLL_EXP CListWidget :
	public CContainerWidget
{
public:
	CListWidget(void){
		m_nItem=0;
		m_pBkSurface=NULL;
		InsertWidget(&m_listContainer);
		InsertWidget(&m_bkWidget,Z_ORDER_BACKGROUND);
		InsertWidget(&m_maskWidget,Z_ORDER_TOPMOST);
		m_maskWidget.SetBackgroundColor(MOUSE_OVER_COLOR);
		m_pFloatItem=NULL;
		m_bEnableFloatItem=true;
		m_bAnimateEffect=true;
		m_pSelectedItem=NULL;
		m_pLastSelectedItem=NULL;
		m_pLastUnderWidget=NULL;
		m_pFocusWidget=NULL;

#ifdef _DEBUG
		 m_clsName="CListWidget";
#endif

	};
	virtual ~CListWidget(void){	
		if(m_pBkSurface!=NULL)
		{
			delete m_pBkSurface;
		}
	};
public:
	int m_nItem;
	bool m_bAnimateEffect;

	CContainerWidget m_listContainer;
	CBackGroundWidget m_bkWidget;
	CMaskWidget m_maskWidget;
	CMemoryFrameSurface* m_pBkSurface;
	CWidget* m_pSelectedItem;
	bool m_bEnableFloatItem;
	CWidget* m_pFloatItem;
	CWidget* m_pLastUnderWidget;
	CWidget* m_pLastSelectedItem;
	CWidget* m_pFocusWidget;
	virtual void HandleModelEvent(ModelEvent* pEvent);
	virtual bool Scroll(int dx,int dy);
	virtual bool IsContinueWhileOutView();
	virtual int SetRect(WRect* pRect,bool bNoDraw=true);
	static void HandleAnimateListener(void *pUserData, ModelEvent *pEvent);
	virtual BOOL RemoveItem(CWidget* pItem);
	virtual BOOL RemoveItem(int nIndex);
	virtual BOOL AddItem(CWidget* pItem,int nIndex=-1);
	virtual  CWidget* GetItem(WPoint* pt);
	virtual  void DockFloatWidget();
	virtual  void GetDockPosition(CWidget* pW,int& x,int& y);
	virtual  void HandleFloatItemMove(WPoint& pt);
	virtual  CWidget* GetSelectedItem();
	virtual void HandleItemSelected(CWidget* pItem);
	virtual bool HandleKeyDown(unsigned int nChar,unsigned int nRepCnt,unsigned int nFlags);
	virtual  bool HandleMouseEvent(int evCode, WPoint* ptScreen, int param2);
	
};
